﻿using MbUnit.Framework;
using TimeStamper.DSL;

namespace TimeStamper.Tests
{
    [TestFixture]
    public class TokenBufferFixtures
    {

        [Test]
        public void Can_Load_And_Peek_At_Two_Tokens_From_Buffer()
        {
            var tokenBuffer = new TokenBuffer(new StringCharacterBuffer("TODAY TOMMOROW", 3), 2);
            Assert.AreEqual(tokenBuffer.Peek(1).Kind, TokenKind.TODAY);
            Assert.AreEqual(tokenBuffer.Peek(2).Kind, TokenKind.TOMMOROW);
        }

        [Test]
        public void If_Buffer_Load_Exceeds_Length_EOF_Token_Will_Fill_Space()
        {
            var tokenBuffer = new TokenBuffer(new StringCharacterBuffer("TODAY TOMMOROW", 3), 2);
            Assert.AreEqual(tokenBuffer.Peek(1).Kind, TokenKind.TODAY);
            Assert.AreEqual(tokenBuffer.Peek(2).Kind, TokenKind.TOMMOROW);

            tokenBuffer.Load(2);
            Assert.AreEqual(tokenBuffer.Peek(1).Kind, TokenKind.EOF);

            //EOF token also present in second buffer chunk
            Assert.AreEqual(tokenBuffer.Peek(2).Kind, TokenKind.EOF);
        }

    }
}